Core

The XType framework provides a standardized mechanism for reading Java objects from a XML representation. There are four components that build the framework:

  • XType.java

    The class XType provides a static method "getObjectFromXML" that can be called by a client. The method expect as parameters an "org.w3c.dom.Element" that contains the XML representation of the Java object, a string that contains the fully qualified type of the object (for example "java.util.Hashtable") and a string that contains the name of the XML tag uses in the XML representation of the object.
  • XTypeUtil.java

    The class XTypeUtil is a helper class that provides functionality for the configuration of XType. The class XType calls XTypeUtil in order to get the configuration information for the type of object that is should build from the XML element. The main configuration information is the name of the class that implements the transformation of the XML element into the correspondig Java class. This information is read by XTypeUtil from a configuration XML file (xtype.xml).
  • XObjectConfig.java

    The class XObjectConfig contains the configuration information for the Java objects to build. At the moment this is only the name of the class that implements the transformation of the XML element into the Java class. The class XTypeUtil returns a hashtable with XObjectConfig values when called from XType.
  • XObject.java

    XObject.java is the interface that the classes which implement the transformation of the XML element into the Java class have to implement. The interface defines a "getObject" method. This method has two parameters, the XML element and a string for the name of the XML tag in the element. Whoever wants to write an own transformation for a Java class has to write a class that implements this interface.

The follwoing sequence diagram visualizes the connection between the four components of XType:

USER                   XType            XTypeUtil            XObjectConfig            XObject
----                   -----            ---------            -------------            -------
 |                       |                  |                      |                     |
 | getObjectFromXML(Element, String type, String itemTagText)      |                     |
 |---------------------->|                  |                      |                     |
 |                       |                  |                      |                     |
 |                       | getInstance()    |                      |                     |
 |                       |----------------->|                      |                     |
 |                       |<-----------------|                      |                     |
 |                       |                  |                      |                     |
 |                       | getObjectConfig(String type)            |                     |
 |                       |----------------->|                      |                     |
 |                       |<-----------------|                      |                     |
 |                       |                  |                      |                     |
 |                       |           getClassType()                |                     |
 |                       |---------------------------------------->|                     |
 |                       |<----------------------------------------|                     |
 |                       |                  |                      |                     |
 |                       |                       getObject(Element, String itemTagText)  |
 |                       |-------------------------------------------------------------->|
 |                       |<--------------------------------------------------------------|
 |                       |                  |                      |                     |
 |<----------------------|                  |                      |                     |
 |                       |                  |                      |                     |